//
//  SimpeWebImageTests.m
//  WeChatMomentsTests
//
//  Created by Jiang on 2019/8/26.
//  Copyright © 2019 SilverFruity. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "ImageCollectionLayoutCalculator.h"

@interface SimpeWebImageTests : XCTestCase

@end

@implementation SimpeWebImageTests

- (void)setUp {
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    
}

- (void)testExample {
    ImageCollectionLayoutCalculator *calculator = [self generatorWithItemCount:1];
    XCTAssert(calculator.viewWidth == 100);
    XCTAssert(calculator.viewHeight == 100);
    
    calculator = [self generatorWithItemCount:2];
    XCTAssert([calculator rowCount] == 1);
    XCTAssert([calculator columnCount] == 2);
    XCTAssert(calculator.itemSize.width == 95);
    
    calculator = [self generatorWithItemCount:3];
    XCTAssert([calculator rowCount] == 2);
    XCTAssert([calculator columnCount] == 2);
    XCTAssert(calculator.itemSize.width == 95);
    
    calculator = [self generatorWithItemCount:4];
    XCTAssert([calculator rowCount] == 2);
    XCTAssert([calculator columnCount] == 2);
    XCTAssert(calculator.itemSize.width == 95);
    
    calculator = [self generatorWithItemCount:5];
    XCTAssert([calculator rowCount] == 2);
    XCTAssert([calculator columnCount] == 3);
    XCTAssert(calculator.itemSize.width == 90);
    
    calculator = [self generatorWithItemCount:6];
    XCTAssert([calculator rowCount] == 2);
    XCTAssert([calculator columnCount] == 3);
    XCTAssert(calculator.itemSize.width == 90);
    
    calculator = [self generatorWithItemCount:7];
    XCTAssert([calculator rowCount] == 3);
    XCTAssert([calculator columnCount] == 3);
    XCTAssert(calculator.itemSize.width == 90);
    
}
- (ImageCollectionLayoutCalculator *)generatorWithItemCount:(NSInteger)count{
    return [ImageCollectionLayoutCalculator calculatorWithItemCount:count
                                                         cellMargin:10
                                             singleItemViewMaxWidth:100
                                               fourItemViewMaxWidth:200
                                               nineItemViewMaxWidth:290];
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

@end
